﻿using System;
using System.Collections.Generic;
using System.Text;
using rkShared.BEncode;
using rkShared.Net;

namespace rkClient
{
   public class ChatClient
    {
       private GameClient m_client;
       private NetMessage m_message;

       public event MessageReceivedEventHandler ChatMessageReceived;
       public ChatClient(GameClient client)
       {
           m_client = client;
           m_client.ChatMessageReceived += new rkShared.Net.MessageReceivedEventHandler(m_client_ChatMessageReceived);
       }
       void m_client_ChatMessageReceived(rkShared.Net.ClientInfo client, rkShared.Net.NetMessage msg)
       {
           if (this.ChatMessageReceived != null)
               this.ChatMessageReceived(null, msg);
       }
       /// <summary>
       /// server a chat mesajlarını gönderir 
       /// </summary>
       /// <param name="message">
       /// BEncodestring tipinde mesaj gönderilir gönderilen bu mesaj 
       /// NetMessage tipinde bir obje olarak 
       /// server a gönderilir
       /// </param>
       public void SendMessageToServer(BEncodedString message)
       {
           m_message = new NetMessage();
           m_message.Data = message;
           m_message.MessageType = MessageType.Chat;
           m_client.SendTCPMessage(m_message);
       }
    }
}
